package com.yangli.leecode.mashib.interview;

import java.math.BigDecimal;

/**
 * @Description
 * @Author liyang
 * @Date 2023/2/6 13:32
 */
public class Nine {
    public static void main(String[] args){

        Nine nine = new Nine();
        System.out.println(nine.MaxSubSum(new int[]{-1, 3, 4, 5, -12, 8, 2, 7}));

       BigDecimal data =  new BigDecimal(0);

        if (data.compareTo(new BigDecimal("0.00")) < 0) {
            System.out.println("false");
        }


        }


    public int MaxSubSum(int[] arr){
        if (arr == null || arr.length == 0) {
            return 0;
        }
        int ans = 0;
        int preSum = 0;
        for (int i = 0; i < arr.length; i++) {
            preSum += arr[i];
            if (preSum > 0) {
                ans = Math.max(ans, preSum);
            } else {
                preSum = 0;
            }
        }
        return ans;
    }

}
